package com.yulongtian.oneProblemEveryDay.month202301;

/**
 * https://leetcode.cn/problems/strong-password-checker-ii/
 * 可
 *
 * @author yulongTian
 * @create 2023-01-19 15:38
 */
public class Test14 {
    public static void main(String[] args) {
        System.out.println(strongPasswordCheckerII("IloveLe3tcode!"));
    }

    public static boolean strongPasswordCheckerII(String password) {
        boolean len = true;
        boolean small = false;
        boolean big = false;
        boolean digital = false;
        boolean special = false;
        boolean sequence = true;
        if (password.length() < 8) {
            len = false;
        }
        char c = password.charAt(0);
        if (c >= 'a' && c <= 'z') {
            small = true;
        } else if (c >= 'A' && c <= 'Z') {
            big = true;
        } else if (c >= '0' && c <= '9') {
            digital = true;
        } else {
            special = true;
        }
        for (int i = 1; i < password.length(); i++) {
            c = password.charAt(i);
            if (c >= 'a' && c <= 'z') {
                small = true;
            } else if (c >= 'A' && c <= 'Z') {
                big = true;
            } else if (c >= '0' && c <= '9') {
                digital = true;
            } else {
                special = true;
            }
            if (password.charAt(i) == password.charAt(i - 1)) {
                sequence = false;
            }
        }

        return len && small && big && digital && special && sequence;
    }

}
